import { renderStart } from '@/model/type'

export const columns = context => {
  return [
    {
      prop: 'customerName',
      headCheck: '1',
      label: '客户名称'
    },
    {
      label: '客户类型',
      headCheck: '0',
      prop: 'customerType'
    },
    {
      prop: 'tradeType',
      headCheck: '1',
      label: '客户行业'
    },
    {
      label: '客户状态',
      headCheck: '1',
      prop: 'customerStatus'
    },
    {
      prop: 'linkMan',
      headCheck: '1',
      label: '对接人'
    },
    // 新增所属业务员
    {
      prop: 'belongRealName',
      headCheck: '1',
      label: '所属业务员'
    },
    {
      prop: 'star',
      label: '客户级别',
      headCheck: '0',
      render: (h, row) => {
        return <div class="text-warning fs16">{renderStart(row.customerStar)}</div>
      }
    },
    {
      prop: 'createTime',
      label: '创建时间',
      headCheck: '1',
      width: 200
    },
    {
      button: true,
      label: '操作',
      headFixed: '1',
      fixed: 'right',
      width: 200,
      render: (h, row) => {
        const edit = (
          <a
            href="javascript:;"
            class="text-primary"
            onClick={() => {
              context.onEdit(row)
            }}
          >
            编辑
          </a>
        )

        const detail = (
          <a
            href="javascript:;"
            class="text-primary"
            onClick={() => {
              context.onDetail(row)
            }}
          >
            详情
          </a>
        )
        const del = (
          <a
            href="javascript:;"
            class="text-error"
            onClick={() => {
              context.onDel(row)
            }}
          >
            删除
          </a>
        )
        // isAction 0 不可操作 1可操作
        return row.isAction === 1 ? [edit, detail, del] : [detail]
      }
    }
  ]
}
